package com.huidu.bitrade.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huidu.bitrade.entity.LoginInfo;
import com.huidu.bitrade.entity.Member;
import com.huidu.bitrade.mapper.MemberMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class LoginInfoService {

    @Autowired
    private MemberMapper memberMapper;

    public LoginInfo getLoginInfo(Member member, String token, Boolean signInActivity, String prefix){
        //查询1级好友列表
        long firstLevel = memberMapper.selectCount(Wrappers.<Member>lambdaQuery()
                .eq(Member::getInviterId,member.getId()));
        //查询2级好友列表
        long secondLevel = memberMapper.findTwoLevelCount(member.getId());
        return LoginInfo.getLoginInfo(member, token, signInActivity, prefix,firstLevel,secondLevel);
    }
}
